package chendu.mapper;

import chendu.entity.PhoneSpecs;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface PhoneSpecsMapper {

    //根据手机查询手机的规格
    @Select("select * from phone_specs where phone_id = #{phoneId}")
    List<PhoneSpecs> findAllByPhoneId(@Param("phoneId") Integer phoneId);

    //根据specs_id查询对应的手机全部信息
    @Select("select * from phone_specs where specs_id = #{specsId}")
    PhoneSpecs findById(@Param("specsId") Integer specsId);

    //在支付成功后，修改商品库存：update table_name set column_name = value where column_name = value;
    @Update("update phone_specs set specs_stock = #{specsStock} where specs_id = #{specsId}")
    void save(Integer specsStock,Integer specsId);
}
